﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ZSZ.Core.Entities;

namespace ZSZ.EntityFramework.ModelConfig
{
    class RegionConfig: EntityTypeConfiguration<RegionEntity>
    {

        public override void Map(EntityTypeBuilder<RegionEntity> builder)
        {
            builder.ToTable("T_Regions");
            builder.Property(p => p.Name).IsRequired().HasMaxLength(50);

            builder.HasOne(p => p.City).WithMany().HasForeignKey(r => r.CityId).OnDelete(DeleteBehavior.ClientSetNull);
        }
    }
}
